package ca.sfu.util;



import edu.cmu.tetradapp.model.EditorUtils;

import edu.cmu.tetrad.graph.*;

import edu.cmu.tetradapp.model.*;



import javax.imageio.ImageIO;

import javax.swing.*;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.IOException;



public class SaveGraphInDot extends AbstractAction {

	

	private JComponent comp;

	private AlgorithmRunner runner;

	public SaveGraphInDot(JComponent comp, AlgorithmRunner runner, String actionName){

		super(actionName);

		

	       if (comp == null) {

	            throw new NullPointerException("Component must not be null.");

	        }

	        this.comp = comp;	

	        this.runner = runner;

	}

	

	public void actionPerformed(ActionEvent e)

	{

		File file = EditorUtils.getSaveFile("graph", "dot", comp, false);

		DotFileGenerator dotOutput = new DotFileGenerator(runner.getResultGraph(),file);

		dotOutput.run();

	}

}

